// utils/auth.js
export function authPage(pageObj) {
  const originalOnLoad = pageObj.onLoad || function() {}
  
  pageObj.onLoad = function(options) {
    if (!getApp().globalData.isLoggedIn) {
      wx.showModal({
        title: '未登录',
        content: '请先登录以继续',
        confirmText: '立即登录',
        success: (res) => {
          if (res.confirm) getApp().showLoginModal()
          else wx.navigateBack() // 或跳转到首页
        }
      })
    }
    originalOnLoad.call(this, options)
  }
  
  return pageObj
}